package com.acme.task1;

public class Calculator {
	final static String errArgs = "Error: too less arguments";
	final static String errOperand = "Error: the first operand is not a number";
	final static String errSecondOperand = "Error: the second operand is not a number";
	final static String errOperandType = "Error: wrong operation type";

	public static void main(String[] args) {
		// analyze number of arguments
		if (args.length < 3) {
			System.out.println(errArgs);
			return;
		}

		// get arguments

		double operand1;
		double operand2;

		try {
			operand1 = Double.parseDouble(args[0]);
		} catch (Exception e) {
			System.out.println(errOperand);
			return;
		}

		try {
			operand2 = Double.parseDouble(args[2]);
		} catch (Exception e) {
			System.out.println(errSecondOperand);
			return;
		}

		char operand;
		// operand = args[1][0];
		operand = args[1].charAt(0);

		// analyze operation and make calculations

		switch (operand) {
		case '+':
			System.out.println(operand1 + operand2);
			break;

		case '-':
			System.out.println(operand1 - operand2);
			break;

		case 'x':
			System.out.println(operand1 * operand2);
			break;

		case '/':
			System.out.println(operand1 / operand2);
			break;

		default:
			System.out.println(errOperandType);
			break;
		}

	}
}
